/*
 *  main.cpp
 *  SCMS
 *
 *  Created by poiuy_qwert on 06/07/09.
 *
 */

#include "PCX.h"
#include "FNT.h"
#include "Palettes.h"
#include "BMP.h"
#include "ByteCodeHandler.h"
#include "AIBIN.h"
#include "TBL.h"
#include "Exception.h"
#include "Logging.h"

#include <fstream>
#include <cstring>

int main(int argc, char * const argv[]) {
	SCMSLog.set("stdeo.txt");
	FNT *fnt = new FNT("font16.fnt");
	PCX *pcx = new PCX("tfontgam.pcx", true);
	BMP *bmp = new BMP(pcx->get_planes(), pcx->get_width(), pcx->get_height(), pcx->get_palette());
	bmp->save_file("tfontgam.bmp");
	
	Palette *pal = pcx->get_palette(0);
	RGB color = {50,100,50};
	pal->set_color(0, color);
	bmp = new BMP();
	bmp->set_palette(pal);
	char filename[8];
	filename[7] = 0;
	for (int i = fnt->get_low(); i < 256; i++) {
		bmp->set_plane(fnt->get_letter(i), fnt->get_width(), fnt->get_height());
		sprintf(filename, "%03u.bmp", i);
		bmp->save_file(filename);
	}
	fnt->export_file("font16.bmp", pal);

	TBL *tbl = new TBL("stat_txt.tbl");
	VariableHandler *vars = new VariableHandler(&AIByteCodeHandler);
	vars->open_definition("unitdef.txt");
	AIBIN ai(tbl, vars);
	ai.open_file("aiscript.bin");
//	set<unsigned long> ids;
//	char id[5] = "Ter3";
//	ids.insert(*(unsigned long*)id);
	ai.export_file("test.txt");
//	ai.import_file("test.txt");
    return 0;
}